#include <iostream>
#include <vector>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        
        bool flag = false;
        
        for (int i = 0; i < n; ++i) {
            if (a[i] == 0) {
                if (i > 0 && a[i-1] != 1) { flag = true; break; }
                if (i < n-1 && a[i+1] != 1) { flag = true; break; }
            }
        }
        
        if (flag) { cout << "YES\n"; continue; }
        
        int ones = 0;
        for (int num : a) ones += num;
        
        cout << (ones > n-1 ? "YES\n" : "NO\n");
    }
    return 0;
}
